<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-menu"></i>{{$route.name}}
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="handle-box">
        </div>
        <div>
            <el-form ref="form" :model="form" label-width="200px">
                <el-form-item prop="serverUrl" label="局域网流媒体服务器URL:">
                    <el-input v-model="form.serverUrl"></el-input>
                </el-form-item>
                <el-form-item prop="downloadUrl" label="局域网电影视频下载URL:">
                    <el-input v-model="form.downloadUrl"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="info" @click="saveSetting">保存</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>
<script>
import { setFilmConfig, getFilmConfig } from '../../api/server.js'
export default {
    data() {
        return {
            form: {
                serverUrl: '',
                downloadUrl: ''
            }
        }
    },
    created() {
        this.getConfig()
    },
    methods: {
        saveSetting() {
            console.log('form', this.form)
            let serverUrl = this.form.serverUrl
            let downloadUrl = this.form.downloadUrl
            setFilmConfig({ serverUrl, downloadUrl })
                .then(res => {
                    this.$message.success('设置成功')
                })
        },
        getConfig() {
            getFilmConfig()
                .then(res => {
                    if (res.code === '000000') {
                        this.form.serverUrl = res.result[0].server_url
                        this.form.downloadUrl = res.result[0].download_url
                    }
                })
        }
    }
}
</script>
<style lang="scss" scoped>
.handle-box {
  margin-bottom: 2%;
  .search {
    width: 30%;
  }
}

.block {
  text-align: center;
  margin-top: 1%;
}
</style>